package com.zhkj.txg.module.order.popup

import android.content.Context
import android.view.Gravity
import android.view.View
import android.view.animation.Animation
import com.zhkj.txg.R
import razerdp.basepopup.BasePopupWindow

class OrderReceiveStatusPopupWindow(
    context: Context,
    val onSelected: (index: Int, content: String) -> Unit
) : BasePopupWindow(context) {

    init {
        popupGravity = Gravity.BOTTOM
    }

    private var viewRefundReceived: View? = null
    private var viewRefundNotReceived: View? = null

    override fun onCreateContentView(): View = createPopupById(R.layout.popup_receive_refund)
    override fun onCreateShowAnimation(): Animation = getTranslateVerticalAnimation(1f, 0f, 300)
    override fun onCreateDismissAnimation(): Animation = getTranslateVerticalAnimation(0f, 1f, 300)

    override fun onViewCreated(contentView: View?) {
        contentView?.findViewById<View>(R.id.ivRefundReceiveClose)?.setOnClickListener {
            dismiss()
        }
        viewRefundReceived = contentView?.findViewById(R.id.viewRefundReceived)
        viewRefundNotReceived = contentView?.findViewById(R.id.viewRefundNotReceived)
        viewRefundReceived?.setOnClickListener {
            it.isSelected = true
            viewRefundNotReceived?.isSelected = false
            onSelected(1, context.getString(R.string.refund_goods_status_receive))
            dismiss()
        }
        viewRefundNotReceived?.setOnClickListener {
            it.isSelected = true
            viewRefundReceived?.isSelected = false
            onSelected(0, context.getString(R.string.refund_goods_status_not_receive))
            dismiss()
        }
    }
}